package com.sun.abilities.thread.application;

import java.util.Observable;
import java.util.Observer;

public class ObServ1 implements Observer,Runnable{
	private int num = 0;
	
	public synchronized void update(Observable o, Object arg) {
		num = Integer.class.cast(arg);
		System.out.println("ObServ1 update , change img = " + ObObject.class.cast(o).getMsg());
		System.out.println("obServ1 执行");
		this.notify();
	}

	public synchronized void run() {
		try {
			System.out.println("obServ1 待命");
			this.wait();
			for (int i = 0; i < num; i++) {
				System.out.println("ObServ1 run ... i = " + i);
			}
			run();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
